<?php


//include('Person.php');



class Admin /*extends Person*/{




	                  /***********************************/
           	         /*function delete existing category*/
	                /*and all related questions to cat */
				   /***********************************/

	public function Delete_Category(){

include('DB.php');

		          $db= new DB;
		
		
		

				  // first SQL query here 
				  //delete all data of the given id and related ques.
				  //doesn't delete category if these is no related questions
				  
				  
				 /* $Sql =" DELETE FROM categorys left join product 
					where 
					categorys.Category_Id = product.Category_Id
					and  
				   categorys.Category_Id= $_POST[Id] ;
				   ";
				  */
				  
				 /* $Sql=" DELETE 
                         FROM categorys
                         INNER JOIN product 
                         ON
	                     categorys.Category_Id = product.Category_Id
                         WHERE 
						 categorys.Category_Id= $_POST[Id];";
				  */
				 $Sql= "DELETE FROM categorys 
						WHERE categorys.Category_ID = $_POST[Id]";
				  
                 $Que=$db->Query($Sql);

				 if ($Que){

                  echo "Deleted category successfully and its related Products<br />";
				  echo'<br/><br/><a href="main.php">Back To main in 3 Seconds...</a>
                  <meta http-equiv="refresh" content="3;url=main.php">';
				  
				  
				  //this query solve the problem of the prevoius Query
				  // delete category even if there is no related questions
				 /* 
				  $Sql = "DELETE from categorys where Category_Id=$_POST[Id]";
                  $Que=$db->Query($Sql);
*/ 
				  
				  }
				 
				 
			else {
                    echo "Didn't Delete";
					echo'<br/><br/><a href="main.php">Back To main in 15 Seconds...</a>
<meta http-equiv="refresh" content="15;url=main.php">';
                 }
				 
				 $db->Disconnect();//close connection
                 unset($db); // destroy DB obj
				 


}





}







?>

